package com.zirenx.utils;

import com.jfinal.aop.Inject;
import com.jfinal.log.Log;
import com.zirenx.sys.service.SysLogService;

import javax.servlet.http.HttpServletRequest;

/**
 * 日志工具
 */
public class LogUtils {

    private static final SysLogService sysLogService = new SysLogService();

    public static void error(Class<?> clazz,Exception e){
        Log log = Log.getLog(clazz);
        log.error(e.getMessage(),e);
        sysLogService.saveLog(clazz,e);
    }

    public static void warn(Class<?> clazz, String msg, HttpServletRequest request){
        Log log = Log.getLog(clazz);
        log.warn(msg);
        sysLogService.saveLog(request,clazz,msg);
    }
}
